home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_Patrol1.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.4 KB  |  192 lines

  1.  
  2.  
  3. //------------------------------------------------------------------
  4. // NOTE: The fsm name below MUST be changed in order for the
  5. // script to be considered a unique entity!
  6.  
  7. UIFIELDS
  8. {
  9. FIELD<INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  10. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  11.  
  12. FIELD<          INT,path,"Path",-1>;                // My path
  13. FIELD<          INT,moveType,"Nocycle = 1, Circle = 2, Seesaw = 3",2>;            // How I move along the path
  14.  
  15. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  16. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  17. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  18. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  19. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  20.                                                     // and other things.  It indicates a general level of combat experience.
  21. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?
  22.         
  23. FIELD<INT,            speed,"Movement Speed",600>;        
  24. FIELD<INT,            takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  25. }
  26.  
  27.  
  28.  
  29. fsm Generic_Patrol : integer;
  30.  
  31.  
  32. //------------------------------------------------------------------
  33.  
  34. // Generic_Patrol:
  35. //   Follows a path.  If anything comes near, it goes off and attacks it,
  36. //   and then comes back to the path when there's nothing left to attack.
  37.  
  38. //------------------------------------------------------------------
  39.  
  40.  
  41.  
  42. //------------------------------------------------------------------
  43. //     Constants
  44. //------------------------------------------------------------------
  45.  
  46.     const
  47.         #include_ <content\ABLScripts\mwconst.abi>
  48.  
  49. //------------------------------------------------------------------
  50. //     Types
  51. //------------------------------------------------------------------
  52.  
  53.     type
  54.         #include_ <content\ABLScripts\mwtype.abi>
  55.     
  56.  
  57. //------------------------------------------------------------------
  58. //     Variables
  59. //------------------------------------------------------------------
  60.  
  61.     var
  62.         static integer            attackRange;        // At what range do I start shooting?
  63.         static integer            withdrawRange;        // At what range do I withdraw from combat entirely?
  64.  
  65.         static integer            path;                // My path
  66.         static integer            moveType;            // How I move along the path
  67.         static boolean            canLeavePath;        // Can I leave the path if attacked? (TRUE by default)
  68.  
  69.         static integer            piloting;            // Piloting skill
  70.         static integer            gunnery;            // Gunnery skill/chance to hit
  71.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  72.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  73.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  74.                                                     // and other things.  It indicates a general level of combat experience.
  75.         static integer            attackThrottle;        // My attack throttle
  76.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  77.         static integer            findTypes;            // What kind of enemies to look for
  78.  
  79.         static integer             attackSound;        // The attack sound I play when I first attack
  80.         static integer             deathSound;            // The sound I play when I die
  81.         
  82.         static integer            mood;                // My default mood.
  83.         static integer            speed;                // The speed at which I move along the path
  84.  
  85.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  86.  
  87. //------------------------------------------------------------------
  88. //     Init: my initialization function
  89. //------------------------------------------------------------------
  90.  
  91. function Init;
  92.     code
  93.         // script-specific variables
  94.         attackRange        = <attackrange>;
  95.         withdrawRange    = <withdrawrange>;
  96.         path            = <path>;
  97.         moveType        = <movetype>;
  98.         canLeavePath    = true;
  99.         speed            = <speed>;
  100.         takeOffDistance    = <takeoffdistance>;
  101.  
  102.         // driver settings
  103.         piloting        = <piloting>;
  104.         gunnery            = <gunnery>;
  105.         minDelay        = <mindelay>;
  106.         maxDelay        = <maxdelay>;
  107.         eliteLevel        = <elitelevel>;
  108.         attackThrottle    = 80;
  109.         isShotRadius    = <isshotradius>;
  110.         attackSound        = -1; // no sound
  111.         deathSound        = -1; // no sound
  112.         mood            = NEUTRAL_START;
  113.         findTypes        = FT_DEFAULT;
  114.  
  115. endfunction;
  116.  
  117. //------------------------------------------------------------------
  118. //    StartState: my initial state
  119. //------------------------------------------------------------------
  120.  
  121. state StartState;
  122.  
  123.     code
  124.         SetFiringDelay            (ME,minDelay,maxDelay);
  125.         SetIgnoreFriendlyFire    (ME,true);
  126.         SetIsShotRadius            (ME,isShotRadius);
  127.         SetEntropyMood            (ME,mood);
  128.         SetCurMood                (ME,mood);
  129.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  130.         SetAttackThrottle        (ME,attackThrottle);
  131.  
  132.         if (orderTakeOff(takeOffDistance) == true) then
  133.             trans FollowPathState;
  134.         endif;
  135.  
  136. endstate;            
  137.  
  138. //------------------------------------------------------------------
  139. //    FollowPathState: follow our path, but keep an eye out for enemies
  140. //------------------------------------------------------------------
  141.  
  142. state FollowPathState;
  143.     code
  144.         if (FindEnemy(attackRange,findTypes)) then
  145.             trans AttackState;
  146.         endif;
  147.  
  148.         if (path <> -1) then
  149.             OrderMoveResumePatrol(path,speed,moveType,true,false);
  150.         else
  151.             OrderMoveLookOut;
  152.         endif;
  153. endstate;
  154.  
  155. //------------------------------------------------------------------
  156. //    AttackState: attack my current target, or return to path if done
  157. //------------------------------------------------------------------
  158.  
  159. state AttackState;
  160.     code
  161.         if (LeaveAttackState(withdrawRange)) then
  162.             OrderStopAttacking;
  163.             SetTarget(ME,NO_UNIT);
  164.             trans FollowPathState;
  165.         endif;
  166.  
  167.         if (attackSound <> -1) then    
  168.             PlaySoundOnce(attackSound);
  169.         endif;
  170.  
  171.         OrderAttack(canLeavePath);
  172.  
  173. endstate;
  174.  
  175. //------------------------------------------------------------------
  176. //    DeadState: OK, I kicked the bucket.
  177. //------------------------------------------------------------------
  178.  
  179. state DeadState;
  180.     code
  181.         if (deathSound <> -1) then    
  182.             PlaySoundOnce(deathSound);
  183.         endif;        
  184.  
  185.         orderDie;
  186.  
  187. endstate;
  188.  
  189.  
  190. endfsm.
  191.  
  192.